package com.ruoyi.project.wenyanwen.generate.domain;


import com.ruoyi.common.constant.DbGenerateResult;
import com.ruoyi.common.constant.DbGenerateStatus;

/**
 * @author jackyshi
 */
public class GenerateTask {

    private int result = DbGenerateResult.SUCCESS;

    private int status = DbGenerateStatus.FINISH;

    private TaskMonitor monitor;

    private DbGenerate dbGenerate;

    private String dbPath;

    private String errorMsg;

    private int total;

    private int finish;

    private long start;

    private long end;

    private int version;

    public int getProgress() {
        if (total == 0) {
            return 100;
        }
        return finish * 100 / total;
    }

    public void addFinish(int count) {
        this.finish += count;
    }

    public int getUseTime() {
        return (int) (end - start);
    }

    public boolean isSuccess() {
        return this.result == DbGenerateResult.SUCCESS;
    }

    public boolean isStop() {
        return this.monitor.isStop();
    }

    public TaskMonitor getMonitor() {
        return monitor;
    }

    public void setMonitor(TaskMonitor monitor) {
        this.monitor = monitor;
    }

    public DbGenerate getDbGenerate() {
        return dbGenerate;
    }

    public void setDbGenerate(DbGenerate dbGenerate) {
        this.dbGenerate = dbGenerate;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getFinish() {
        return finish;
    }

    public void setFinish(int finish) {
        this.finish = finish;
    }

    public String getDbPath() {
        return dbPath;
    }

    public void setDbPath(String dbPath) {
        this.dbPath = dbPath;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public int getResult() {
        return result;
    }

    public void setResult(int result) {
        this.result = result;
    }

    public long getStart() {
        return start;
    }

    public void setStart(long start) {
        this.start = start;
    }

    public long getEnd() {
        return end;
    }

    public void setEnd(long end) {
        this.end = end;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }
}
